package beans.impl;

import beans.ProductStore;
import javax.ejb.Remote;
import javax.ejb.Stateful;
import beans.EcomAdminRemote;
import java.util.ArrayList;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Interface d'administration
 * @author M2 MIAGE Apprentissage - Groupe 3
 */
@Stateful
@Remote(EcomAdminRemote.class)
public class EcomAdminBean implements EcomAdminRemote{

    @PersistenceContext
    private EntityManager entityManager;

    public void createAccount(String accountId, String accountOwner, double balance) {
       AccountBean account = new AccountBean(accountId, accountOwner, balance);
       // todo ajouter dans la base
    }
    public void createProductStore(int productStoreId, String city, String productStoreAccountId, String productStoreName){
        ProductStoreBean productStore = new ProductStoreBean(productStoreId, city, entityManager.find(AccountBean.class, productStoreAccountId), productStoreName);
    }

    public void createProduct(String reference, String productName, double productPrice, ArrayList<Integer> productStoreList){
        ProductBean product = new ProductBean(reference, productName, productPrice, productStoreList);
        // todo ajouter dans la base
    }
}
